import nprogress from 'nprogress'
import 'nprogress/nprogress.css'
import router from './router/'

router.beforeEach(to => {
  nprogress.start()

  const token = localStorage.getItem('token')
  if (!token && to.path !== '/signin') {
    // router.push('/signin')
    return {
      path: '/signin',
      query: { redirect: to.fullPath },
    }
  }
})

router.afterEach(() => {
  nprogress.done()
})

export default router
